package com.example.shop

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.os.Handler
import android.text.TextUtils
import androidx.lifecycle.lifecycleScope
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.SPUtils
import com.example.base.mvvm.BaseViewActivity
import com.example.shop.databinding.ActivityTimeBinding
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.util.Timer
import kotlin.concurrent.timerTask

class TimeActivity : BaseViewActivity<ActivityTimeBinding>() {
    var time = 5
    override fun initView() {
        lifecycleScope.launch {
            for (i in time downTo 0){
                binding.time= i
                delay(1000)
            }
            //startActivity(Intent(this@TimeActivity,MainActivity::class.java))
            //build()添加的是要跳转的界面  navigation导航到具体路径--一定要写
            //路径格式--/XXX/YYY  注意  XXX:再同一个模块用同一个名字   YYY:不能同名
            if(TextUtils.isEmpty(SPUtils.getInstance().getString("token"))){
                ARouter.getInstance().build("/app/MainActivity").navigation()//不带参数
            }else{
                ARouter.getInstance().build("/app/ShopActivity").navigation()//不带参数
            }

            //ARouter.getInstance().build("/app/MainActivity").withString("username","asdf").navigation()带参数传递
        }
    }
    override fun initData() {
    }
    override fun getLayout(): Int  = R.layout.activity_time

}